package com.ds;

import com.ds.common.JDSConstants;
import com.ds.common.logging.Log;
import com.ds.common.logging.LogFactory;
import com.ds.config.JDSConfig;
import com.ds.config.JDSUtil;
import com.ds.config.UserBean;
import com.ds.esb.config.manager.EsbBeanFactory;
import com.ds.esb.config.manager.ExpressionTempBean;
import com.ds.esb.config.manager.ServiceBean;
import com.ds.esb.util.EsbFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.List;

public class JDSInit extends HttpServlet {
    private static final Log logger = LogFactory.getLog(
            JDSConstants.CONFIG_KEY, JDSInit.class);

    public static final String PRODUCT_NAME = "BSI-JDS VFSTools";

    public static final String PRODUCT_VERSION = "V0.5b";

    public static final String PRODUCT_COPYRIGHT = "Copyright(c)2012 - 2020 itjds.net, All Rights Reserved";


    public void init() throws ServletException {
        try {
            System.setProperty(JDSConfig.JDSHomeName, JDSUtil.getJdsRealPath());
            //System.out.println("jdshome="+JDSUtil.getJdsRealPath());
            System.out.println("************************************************");
            System.out.println("----- 欢迎使用 BSI-JDS VFSTools 管理工具");

            System.out.println(PRODUCT_NAME + " - " + PRODUCT_VERSION);
            System.out.println(PRODUCT_COPYRIGHT);
            System.out.println("************************************************");
            System.out.println("-------- VFSTools Initialization ---------");
            System.out.println("************************************************");


            System.out.println("- Start Connect Server - " + UserBean.getInstance().getServerUrl() + "*");


            System.out.println("- Connent VFSServer RUL    [" + UserBean.getInstance().getServerUrl() + "]*");

            System.out.println("- Connent VFSServer UserName    [" + UserBean.getInstance().getUsername() + "]*");
            EsbFactory.initBus();
            List<? extends ServiceBean> list = EsbBeanFactory.getInstance().loadAllServiceBean();
            for (int k = 0; k < list.size(); k++) {
                if (!(list.get(k) instanceof ExpressionTempBean)) {
                    continue;
                }
                ExpressionTempBean bean = (ExpressionTempBean) list.get(k);
                // System.out.println(bean.getName() + bean.getExpressionArr());
            }
            System.out.println("************************************************");
        } catch (Exception e1) {
            e1.printStackTrace();
        }


    }

}
